<%@ page import="BL.AccessDB"%>
<%@ page import="BL.Eintrag"%>
<%@ page contentType="text/html; charset=ISO-8859-1" language="java"%>


<%
	int xv = 0;
	String plz = request.getParameter("plz");
	String ort = request.getParameter("ort");
	String strasse = request.getParameter("strasse");
	String hausnr = request.getParameter("hausnr");
	String kat = request.getParameter("kategorie");
	String adresse = plz + " " + ort + " " + strasse + " " + hausnr;

	//System.out.println( BL.AccessDB.getErgebnisliste(kat)[0].getName()  );
	Eintrag[] erg = BL.AccessDB.getErgebnisliste(kat);
%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html {
	height: 100%
}

body {
	height: 100%;
	margin: 0px;
	padding: 0px
}

#map_canvas {
	height: 100%
}
</style>
<script type="text/javascript"
	src="https://maps.google.com/maps/api/js?sensor=true">
	
</script>

<script type="text/javascript">
	function initialize() {

		<%/*var geocoder = new google.maps.Geocoder();
		var address = {
			address : adresse
		};*/%>

		var latlng = new google.maps.LatLng(49.34612355056964, 9.13414478302002);
		<%
		/*geocoder.geocode(address, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
				latlng = results[0].geometry.location;
			} else {
				alert("Geocode was not successful for the following reason: "
						+ status);
			}
		});*/%>

		var myOptions = {
			zoom : 13,
			center : latlng,
			mapTypeId : google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("map_canvas"),
				myOptions);

		var marker;
		var arraylength =
<%=erg.length%>
	;
<%for (int i = 0; i < erg.length; i++) {
				out.print("myLatlng = new google.maps.LatLng("
						+ erg[i].getLat() + "," + erg[i].getLang() + ");");
				out.print("marker = new google.maps.Marker({map:map,position : new google.maps.LatLng("
						+ erg[i].getLat()
						+ ","
						+ erg[i].getLang()
						+ "),title : 'Hello World!'});");
				//out.print("google.maps.event.addListener(marker, 'click', function() {infowindow.open(map,marker);});");
				//System.out.println( erg[i].getName() );
			}%>
	// To add the marker to the map, call setMap();

	}


</script>
</head>
<body onload="initialize()">
	<jsp:include page="header.jsp" />
	<div id="map_canvas" style="width: 500px; height: 400px"></div>

	<table>
		<tr>
			<th>Index</th>
			<th>Name</th>
			<th>Entfernung</th>
		</tr>
		<%
			for (int x = 0; x < erg.length; x++) {
				out.println("<tr><td>" + (x + 1) + "</td>");
				out.println("<td>" + erg[x].getName() + "</td>");

			}
		%>
	</table>
	<form>
		<input type="submit" value="Neue Suche" action="./">
	</form>




</body>
</html>